﻿#ifndef CARDPANEL_H
#define CARDPANEL_H

#include <QWidget>
#include "card.h"
#include "player.h"
class CardPanel : public QWidget
{
    Q_OBJECT
public:
    explicit CardPanel(QWidget *parent = nullptr);
    //设置图片
    void setImage(QPixmap &front,QPixmap &back);
    QPixmap getImage();

    //扑克牌显示哪一面
    void setFrontSide(bool flag);
    bool isFrontSide();

    //记录扑克牌是否被选中
    void setSelected(bool flag);
    bool isSelected();

    //扑克牌花色及点数
    void setCard(Card &card);
    Card getCard();

    //扑克牌所有者
    void setOwner(Player* player);
    Player* getOwner();
    //模拟点击事件
    void click();

protected:
    void paintEvent(QPaintEvent *event);
    void mousePressEvent(QMouseEvent *event);

signals:
    void cardSelect(Qt::MouseButton button);
private:
    QPixmap m_front;
    QPixmap m_back;
    bool m_isFront;
    bool m_isSelected;
    Card m_card;
    Player* m_player;

};

#endif // CARDPANEL_H
